home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000225_icon-group-sender _Wed Oct 27 07:57:44 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id HAA09494
  4.     for icon-group-addresses; Wed, 27 Oct 1999 07:57:38 -0700 (MST)
  5. Message-Id: <199910271457.HAA09494@baskerville.CS.Arizona.EDU>
  6. From: gep2@terabites.com
  7. Date: Wed, 27 Oct 1999 01:43:11 -0500
  8. Subject: csets and sets of characters
  9. To: icon-group@optima.CS.Arizona.EDU
  10. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  11. Status: RO
  12.  
  13. > In writing an Icon version of a command line options parser,
  14. like getopt() in C & Perl, I decided to first convert the input
  15. string of option characters (ie. "abc:12:") into two sets of
  16. characters, one for options that take arguments, and one for
  17. options which take no arguments.  This is easy using Icon sets,
  18. but it seems more natural somehow to use the built-in cset
  19. datatype.  But I don't see how to test for members in csets
  20. (member( 'abc', "b" ) generates a run time error).  Any sage
  21. advice out there about when to use sets and/or csets?
  22.  
  23. It SOUNDS like you're trying to write it the way you'd write it in C or Perl, 
  24. and that's usually a bad sign.
  25.  
  26. Usually what I think you really want to do is instead to use string scanning to 
  27. process your options.  This might be very different of course depending on just 
  28. what you're trying to do, but I'd think you'd want something more based on 
  29. something like 
  30.  
  31.    tab(any(noargparms) | (any(argparms) many("0123456789")))
  32.  
  33. Sorry to not provide a more concrete example, but it really does depend on just 
  34. what you're trying to accomplish... and what you want your command line to look 
  35. like.
  36.  
  37. Gordon Peterson
  38. http://web2.airmail.net/gep2/
  39. Support the Anti-SPAM Amendment!  Join at http://www.cauce.org/
  40. 12/19/98: the day the Conservatives demonstrated their scorn for their
  41.    fraudulent sham of representative government.  Voters, remember it!
  42.  
  43.